<%@ include file="/common/taglibs.jsp"%>
<head>
	<title><fmt:message key="ordermodel.title"/></title>
	<script type="text/javascript" src="<c:url value='/ext/scripts/index/index.js'/>"></script>
</head>
<script type="text/javascript"
	src="<c:url value='/ext/scripts/display/displaypage.js'/>">
</script>
<script>
jQuery(function(){
		jQuery("#displayallpage").val(${displayallpage});
		jQuery("#tz").val(${thispage});
	});
</script>

<div class="box_big">
<form:form commandName="orderinfomodel" method="post" action="${ctx}/orderinfomodel/orderinfomodelform.html?method=query&operate=select">
	<div class="tabbiao">
			<div class="r">
				<div class="con">
					<div style="float: left; width: 100%; margin: 0; padding: 0;" onclick="hiddenselectcon();">
						<h6>
							<fmt:message key="order.selectcon" />
						</h6>
					</div>
				</div>
			</div>
		</div>

	<div onclick="hiddenselectcon();"></div>
	<div class="tabcon" id="selectcondiv" style="display: none;">
	<table border="0" cellspacing="0" cellpadding="0" class="table_surch">
		<tr>
			<shiro:hasPermission name="orderinfomodelUsername">
				<th><fmt:message key="ordermodel.userid"/>:</th>
				<td><form:input path="userid" cssClass="text3"/></td>
			</shiro:hasPermission>
			<th><fmt:message key="ordermodel.priority"/>:</th>
			<td>
				<form:select path="priority" cssClass="text4">
					<option value=""><fmt:message key="common.pleaseselect"/></option>
					<c:forEach var="p" items="${prioritymap}">
						<form:option value="${p.key}">${p.value}</form:option>
					</c:forEach>
				</form:select>
			</td>
			<th><fmt:message key="ordermodel.satelliteid"/>:</th>
			<td>
				<form:select id="satelliteid" path="satelliteid" cssClass="text4">
					<option value=""><fmt:message key="common.pleaseselect"/></option>
					<c:forEach var="s" items="${satelliteids}">
						<form:option value="${s}">${s}</form:option>
					</c:forEach>
				</form:select>
			</td>
			<th><fmt:message key="ordermodel.sensorid"/>:</th>
			<td>
				<form:select id="sensorid" path="sensorid" cssClass="text4">
					<option value=""><fmt:message key="common.pleaseselect"/></option>
					<c:forEach var="s" items="${sensorids}">
						<form:option value="${s}" id="old">${s}</form:option>
					</c:forEach>
				</form:select>
			</td>
		</tr>
		<tr>
			<th><fmt:message key="ordermodel.selectstarttime"/>:</th>
			<td colspan="3">
				<form:input id="starttime" path="starttime" onclick="WdatePicker();" cssClass="Wdate text3"/>
				<fmt:message key="order.to"/>
				<form:input path="endtime" id="endtime" onclick="WdatePicker();" cssClass="Wdate text3"/>
			</td>
			
			 <td>
						<input type="submit" class="btn_search"  value=""/>
			</td>
			</tr>
	</table>
	</div>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr height="30">
			<div class="adddi">
			<div class="r">
			<div class="con">
			
				<input type="button"  onclick="javascript:location.href='${ctx}/orderinfomodel/orderinfomodelform.html?method=edit&operate=add'" class="btn_add"/>
			</div>
			</div>
			</div>
			
		</tr>
	</table>
</form:form>
<form id="deleteform" method="post">
<input type="hidden" name="ptmeth" value="${ptmeth}"/>
<input type="hidden" name="tz" value="${thispage}"/>
</form>
<display:table name="ordermodel" style="width:100%" cellspacing="0" cellpadding="0" requestURI="" id="ordermodels" pagesize="${pagesize}" class="table_display" export="true" size="${resultSize}" partialList="true">
	<display:column property="ordermodelid" titleKey="ordermodel.id" style="border-left:1px solid #feb808;"/>
	<display:column titleKey="ordermodel.productlevel">
		<c:forEach var="pl" items="${productlevelsmap}">
			<c:if test="${ordermodels.productlevel!= null && ordermodels.productlevel eq pl.key}">
				${pl.value}
			</c:if>
		</c:forEach>
	</display:column>
	<display:column property="satelliteid" titleKey="ordermodel.satelliteid" maxLength="12"/>
	<display:column property="sensorid" titleKey="ordermodel.sensorid" maxLength="12"/>
	<display:column titleKey="ordermodel.priority">
		<c:forEach var="p" items="${prioritymap}">
			<c:if test="${ordermodels.priority!=null && ordermodels.priority eq p.key}">
				${p.value}
			</c:if>
		</c:forEach>
	</display:column>
	<display:column property="userid" titleKey="ordermodel.creater"/>
	<display:column titleKey="ordermodel.isdefaulmodel">
		<c:forEach var="m" items="${modelmap}">
			<c:if test="${ordermodels.isdefaulmodel!=null && ordermodels.isdefaulmodel eq m.key}">
				${m.value}
			</c:if>
		</c:forEach>
	</display:column>
	<display:column property="createtime" titleKey="ordermodel.createtime" format="{0,date,yyyy-MM-dd}"/>
	<display:column titleKey="ordermodel.operate" media="html">
		<a href="#" onclick="javascript:location.href='${ctx}/orderinfomodel/orderinfomodelform.html?method=view&id=${ordermodels.ordermodelid}'"><fmt:message key="ordermodel.view"/></a>
		<c:if test="${ordermodels.isdefaulmodel != 3}">
			<c:if test="${ordermodels.userid eq localuser.username}">
			<a href="#" onclick="javascript:location.href='${ctx}/orderinfomodel/orderinfomodelform.html?method=edit&operate=edit&id=${ordermodels.ordermodelid}&tz=${thispage}&ptmeth=${ptmeth}'">
			<fmt:message key="ordermodel.edit"/>
			</a>
			<a href="#" onclick="onDelete(${ordermodels.ordermodelid})"><fmt:message key="ordermodel.delete"/></a>
			</c:if>
			<c:if test="${ordermodels.userid ne localuser.username}">
			<fmt:message key="ordermodel.edit"/>
			<fmt:message key="ordermodel.delete"/>
			</c:if>
		</c:if>
		<c:if test="${ordermodels.isdefaulmodel == 3}">
			<shiro:hasPermission name="systemOrderModelEdit">
				<a href="#" onclick="javascript:location.href='${ctx}/orderinfomodel/orderinfomodelform.html?method=edit&operate=edit&id=${ordermodels.ordermodelid}&tz=${thispage}&ptmeth=${ptmeth}'"><fmt:message key="ordermodel.edit"/></a>
				<a href="#" onclick="onDelete(${ordermodels.ordermodelid})"><fmt:message key="ordermodel.delete"/></a>
			</shiro:hasPermission>
			<shiro:lacksPermission name="systemOrderModelEdit">
				<fmt:message key="ordermodel.edit"/>
				<fmt:message key="ordermodel.delete"/>
			</shiro:lacksPermission>
		</c:if>
	</display:column>
	<display:setProperty name="export.pdf" value="false" />
	<display:setProperty name="export.csv" value="false" />
	<display:setProperty name="export.xml" value="false" />
</display:table>
</div>
<script type="text/javascript">
highlightTableRows("ordermodels");
jQuery("#satelliteid").change(function(){
  	var checkText=jQuery("#satelliteid").find("option:selected").text();  
 	jQuery.post("${ctx}/ajax/getsensors.html?method=ajax",{key:checkText},function(data){
 		try {
 			jQuery("#sensorid option[id='old']").remove(); 
 			jQuery.each(data.ingredients,function(idx,item){  
 				jQuery("#sensorid").append("<option id='old' >"+item+"</option>");  
              });  
         } catch(e)
         {
            alert("Error in XML response:"+e);  
         }  
 	},'JSON');
 });
function onDelete(id)
{
	var msg = "<fmt:message key="authoriy.deletemsg"/>";
   	ans = confirm(msg);
   	if(ans)
  		{
    	var form = document.getElementById("deleteform");
    	form.action = "orderinfomodelform.html?method=delete&id="+id;
    	form.submit();
  		}
}
</script>